﻿using Learun.Util;
using System;
using System.Collections.Generic;
using System.Linq;

namespace Learun.Application.TwoDevelopment.ZZDT_EC
{
    /// <summary>
    /// 版 本 PIT-ADMS V7.0.3 敏捷开发框架
    /// Copyright (c) 2013-2018 Hexagon PPM
    /// 创 建：超级管理员
    /// 日 期：2022-06-21 15:32
    /// 描 述：关联类型表
    /// </summary>
    public class ec_SofttagBLL : ec_SofttagIBLL
    {
        ec_SofttagService softTagServ;
        public ec_SofttagBLL()
        {
            softTagServ = new ec_SofttagService();
        }
        #region 获取数据
        /// <summary>
        /// 
        /// </summary>
        /// <param name="ProjectId"></param>
        /// <returns></returns>
        public List<ec_SofttagEntity> GetList(string ProjectId, string wireGroupId)
        {
            IEnumerable<ec_SofttagEntity> softtags = new List<ec_SofttagEntity>();
            if (string.IsNullOrEmpty(wireGroupId) || wireGroupId == "0")
            {
                softtags = softTagServ.GetList("{ProjectId:\"" + ProjectId + "\"}");
            }
            else
            {
                softtags = softTagServ.GetList("{ProjectId:\"" + ProjectId + "\",Wire_Group_ID:\"" + wireGroupId + "\"}");
            }

            return softtags.ToList();
        }
        /// <summary>
        /// 获取列表分页数据
        /// <param name="pagination">分页参数</param>
        /// <summary>
        /// <returns></returns>
        public IEnumerable<ec_SofttagEntity> GetPageList(Pagination pagination, string queryJson)
        {
            try
            {
                return softTagServ.GetPageList(pagination, queryJson);
            }
            catch (Exception ex)
            {
                if (ex is ExceptionEx)
                {
                    throw;
                }
                else
                {
                    throw ExceptionEx.ThrowBusinessException(ex);
                }
            }
        }

        /// <summary>
        /// 获取实体数据
        /// <param name="keyValue">主键</param>
        /// <summary>
        /// <returns></returns>
        public ec_SofttagEntity GetEntity(string keyValue, string ProjectId)
        {
            try
            {
                return softTagServ.GetEntity(keyValue, ProjectId);
            }
            catch (Exception ex)
            {
                if (ex is ExceptionEx)
                {
                    throw;
                }
                else
                {
                    throw ExceptionEx.ThrowBusinessException(ex);
                }
            }
        }

        #endregion
        #region 提交数据
        /// <summary>
        /// 删除实体数据
        /// <param name="keyValue">主键</param>
        /// <summary>
        /// <returns></returns>
        public void DeleteEntity(string ProjectId, string keyValue)
        {
            try
            {
                softTagServ.DeleteEntity(ProjectId, keyValue);
            }
            catch (Exception ex)
            {
                if (ex is ExceptionEx)
                {
                    throw;
                }
                else
                {
                    throw ExceptionEx.ThrowBusinessException(ex);
                }
            }
        }
        /// <summary>
        /// 保存实体数据（新增、修改）
        /// <param name="keyValue">主键</param>
        /// <summary>
        /// <returns></returns>
        public void SaveEntity(string ProjectId, ref string keyValue, ec_SofttagEntity entity)
        {
            try
            {
                softTagServ.SaveEntity(ProjectId, ref keyValue, entity);
            }
            catch (Exception ex)
            {
                if (ex is ExceptionEx)
                {
                    throw;
                }
                else
                {
                    throw ExceptionEx.ThrowBusinessException(ex);
                }
            }
        }
        #endregion
    }
}
